[% setvar title IPC Mailboxes for Threads and Signals %]
<div id="archive-notice">
    <h3>This file is part of the Perl 6 Archive</h3>
    <p>To see what is currently happening visit <a href="http://www.perl6.org/">http://www.perl6.org/</a></p>
</div>
<div class='pod'>
<a name='TITLE'></a><h1>TITLE</h1>
<p>IPC Mailboxes for Threads and Signals</p>
<a name='VERSION'></a><h1>VERSION</h1>
<pre>  Maintainer: Uri Guttman &lt;<a href='mailto:uri@sysarch.com'>uri@sysarch.com</a>&gt;
  Date: 9 Aug 2000
  Mailing List: <a href='mailto:perl6-language-flow@perl.org'>perl6-language-flow@perl.org</a>
  Number: 86
  Version: 1
  Status: Developing</pre>
<a name='ABSTRACT'></a><h1>ABSTRACT</h1>
<p>An IPC mailbox is a simple way for threads (or possibly processes) to
communicate without the mess of directly dealing with
semaphores/mutexes/queues.</p>
<a name='DESCRIPTION'></a><h1>DESCRIPTION</h1>
<p>A mailbox is a combination of a semaphore and a message queue (or
pipe). You put a message into a mailbox and can call get to retrieve
it. The get call can be blocking or non-blocking but it can't be
asynchronous unless it is built with or associated with a pipe/socket.</p>
<p>There can be special mailboxes created which can be used to
synchronously deliver signals and warn/die callbacks. A thread can block
on a signal mailbox and then when it receives the data and wakes up, it
can proceed and safely do any needed work.</p>
<a name='IMPLEMENTATION'></a><h1>IMPLEMENTATION</h1>
<p>Mailboxes can be built in many ways. A single pipe could be used with
just a reference (or C pointer) being passed down it. Then the async I/O
system would handle delivery and the receiving thread could be woken
up. Alternatively it could be a shared memory linked list with a mutex
surrounding it. That would imply only a blocking API.</p>
<a name='IMPACT'></a><h1>IMPACT</h1>
<p>The kind of data you can send to a mailbox is a question. Some RTOSs
have mailboxes where you can only send short data blocks. This is for
efficiency and in many cases the data is just pointers to larger
chunks. We could limit the data in a mailbox to a reference or an object
if that simplifies coding them. Allowing an entire hash tree to be sent
is not a good idea IMO.</p>
<a name='UNKNOWNS'></a><h1>UNKNOWNS</h1>
<p>None</p>
<a name='REFERENCES'></a><h1>REFERENCES</h1>
<p>Event.pm		- XS based event loop module.</p>
<p>RFC #1			- Implementation of Threads in Perl</p>
<p>RFC #47			- Universal Asynchronous I/O (the moby one)</p>
<p>VMS			- It has mailboxes</p>
<p>various RTOSs		- They also have mailboxes</p>
</div>
